package com.smarthospital.dao.daoService;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.smarthospital.dao.mapper.DoctorDao;
import com.smarthospital.entity.pojo.Doctor;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

@Service
public class DoctorDaoService{

    @Resource
    private DoctorDao doctorDao;


    public int insertSelective(Doctor pojo){
        return doctorDao.insertSelective(pojo);
    }


    public int update(Doctor pojo){
        return doctorDao.update(pojo);
    }

    public PageInfo<Doctor> querDoctors(Integer doctorLevel, Integer pageSize, Integer pageNum) {
        PageHelper.startPage(pageNum,pageSize);
        List<Doctor> list = doctorDao.querDoctors(doctorLevel);
        return PageInfo.of(list);
    }

    public Doctor queryById(Long id) {
        return doctorDao.queryById(id);
    }

    public Doctor queryByDoctorStr(String doctor) {
        return doctorDao.queryByDoctorStr(doctor);
    }

    public Doctor queryByIdCard(String idCardNum) {
        List<Doctor> list = doctorDao.queryByIdCard(idCardNum);
        if (list.size() == 1) {
            return list.get(0);
        }
        return null;
    }
}
